<template>
	<div class="diy_edit question_edits" id="question_edit">
	  <el-form
		:model="form"
		ref="ruleFormRef"
		:rules="rules"
		label-width="auto"
		class="edit_question_form"
		size="large"
	  >
    <el-row class="row_e">
        <el-col :xs="24" :sm="24" :lg="24" class="el_form_item_warp">
          <el-form-item label="科目" prop="subject_name">
            <el-input v-model="form.subject_name" :readonly="true"></el-input>
          </el-form-item>
        </el-col>

        <el-col :xs="24" :sm="24" :lg="24" class="el_form_item_warp">
          <el-form-item label="类型" prop="type">
            <el-input v-model="form.type" :readonly="true"></el-input>
          </el-form-item>
        </el-col>

        <el-col :xs="24" :sm="24" :lg="24" class="el_form_item_warp">
          <el-form-item label="题目" prop="title">
            <el-input v-model="form.title" :readonly="true"></el-input>
          </el-form-item>
        </el-col>

         <el-col :xs="24" :sm="24" :lg="24" class="el_form_item_warp">
          <el-form-item label="参考答案" prop="answer">
            <el-input
              v-model="form.answer"
              :readonly="true"
            ></el-input>
          </el-form-item>
        </el-col>

        <el-col :xs="24" :sm="24" :lg="24" class="el_form_item_warp">
          <el-form-item label="选项" prop="question_item">
            <el-input
              type="textarea"
              v-model="form.question_item"
              :readonly="true"  :autosize="{ minRows: 2, maxRows: 10 }">
            </el-input>
          </el-form-item>
        </el-col>

         <el-col :xs="24" :sm="24" :lg="24" class="el_form_item_warp">
          <el-form-item label="提交答案" prop="answers">
            <el-input
              v-model="form.answers"
              :readonly="true"
            ></el-input>
          </el-form-item>
        </el-col>

      </el-row>
		<div class="footer">
		  <el-button @click="cancel()" size="large">取消</el-button>
		</div>
	  </el-form>
	</div>
  </template>
  
  <script setup>
  import { ElMessage } from "element-plus";
  import { ref, onMounted } from "vue";
  import { $post, $get } from "@/api/Api.js";
  import storageHelper from "@/libs/StorageHelper";
  import { useStore } from "vuex";
  import { useRouter } from "vue-router";
  import {
	$get_auth,
	func,
	paramsFun,
	$fullUrl,
	formatDate,
	$banseUrl,
	$check_action,
	$getUrlParams,
	filterSensitiveWords,
  } from "@/utils/utils.js";
  let router = useRouter();
  let store = useStore();
  let token = storageHelper.getToken() || null;
  let UserInfo = storageHelper.getUserInfo();
  let user_answer_id = $getUrlParams().user_answer_id;
  let user_group = storageHelper.getUserInfo().user_group;
  let user_id = storageHelper.getUserInfo().user_id;
  let url_add = ref("/api/user_answer_wrong/add");
  let url_set = ref("/api/user_answer_wrong/set");
  let url_get_obj = ref("/api/user_answer_wrong/get_obj");
  let title = ref("user_answer_wrong");
  let field = ref("user_answer_id");
 //科目
  let list_subject = ref([]);
  let form = ref({
    user_answer_id: 0,
      type: "",
      answers:"",
      subject_name:"",
      title: "",
      question_item: "",
      answer: "",
      score: 0,
      exam_id: 0,
  });
  
  let ruleFormRef = ref(null);
  let rules = ref({
	name: [
	  {
		required: true,
		message: "名称不能为空",
		trigger: "blur",
	  },
	],
  });
  
  // 点击取消
  let cancel = () => {
	router.go(-1);
  };

  // 获取详情
  let get_question_obj = async () => {
	var list = await $get("/api/user_answer_wrong/get_obj?user_answer_id=" + user_answer_id);
	form.value = list.result.obj;
  };
  // 获取科目列表
  let get_subject_list = async () => {
      let json = await $get("/api/subject/get_list");
      if (json.result) {
      list_subject.value = json.result.list;
      } else if (json.error) {
        console.error(json.error);
      }
  }
  onMounted(() => {
    get_question_obj();
    get_subject_list()
    
  });

  </script>
  
  <style scoped lang="less">
  .diy_edit {
	width: 100%;
	.edit_question_form {
	  max-width: 60%;
	  margin: 90px auto;
	  .fn {
		width: 100%;
	  }
	}
	img {
	  width: 100px;
	  height: 100px;
	}
	.edit_list_question_sell {
	  width: 80%;
	  margin: 90px auto;
	}
	.footer {
	  text-align: center;
	}
  }
  </style>
  